package models

import (
	"fmt"
	"github.com/astaxie/beego/orm"
)

const (
	SQL_SUCCESS  = 0  //查询结果ok,
	SQL_EXSIT    = -1 //数据已存在
	SQL_UN_EXSIT = -2 //数据不存在
	SQL_UNKNOW   = -3 //未知错误
)

/**
初始化db
 */
func init() {
	// set default database
	orm.RegisterDataBase("default", "mysql", "root:@/androidblog?charset=utf8", 30)
	//orm.RegisterDataBase("default", "mysql", "username:password@tcp(127.0.0.1:3306)/wanandroid?charset=utf8", 30)

	// register model
	orm.RegisterModel(new(User))
	orm.RegisterModel(new(Collect))
	orm.RegisterModel(new(Article))

	// create table
	orm.RunSyncdb("default", false, true)
	fmt.Println("dbutils 初始化")
}
func checkErr(err error) {
	if err != nil {
		panic(err)
	}
}